<template>
  <el-dialog v-bind="dialogProps" :before-close="handleClose" :close-on-click-modal="false" :destroy-on-close="true"
             v-dialogDrag>
    <vxe-table border stripe ref="selectedEquip" height="300" :data="list.data">
      <vxe-column type="seq" title="序号" width="60" align="center"></vxe-column>
      <vxe-column field="unitName" title="单位名称" align="center" minWidth="150"></vxe-column>
      <vxe-column field="defectName" title="缺陷隐患名称" align="center" minWidth="150">
        <template v-slot="{ row }">
          <span style="color:#0000FF ;" @click="handleBaseInfo(row)">{{ row.defectName }}</span>
        </template>
      </vxe-column>
      <vxe-column field="handleTaskName" title="工单名称" align="center" minWidth="150"></vxe-column>
      <vxe-column field="taskSourceName" title="数据来源" align="center" minWidth="150"></vxe-column>
      <vxe-column field="equipName" title="设备名称" align="center" minWidth="150"></vxe-column>
      <vxe-column field="defectDescription" title="详细描述" align="center" minWidth="150"></vxe-column>
      <vxe-column field="jfName" title="能源站名称" align="center" minWidth="150">
        <template v-slot="{ row }">
          <el-row>
            <span>{{ row.jfName ? row.jfName : '-' }}</span>
          </el-row>
        </template>
      </vxe-column>

      <vxe-column field="equipDefectTypeName" title="问题分类" align="center" minWidth="150"></vxe-column>
      <vxe-column field="creator" title="发现人" align="center" minWidth="150"></vxe-column>
      <!-- <vxe-column field="teamName" title="发现班组" align="center" minWidth="150"></vxe-column> -->
      <vxe-column field="createTime" title="发现日期" align="center" minWidth="180"></vxe-column>
      <!-- <vxe-column field="defectParts" title="缺陷隐患部位" align="center" minWidth="150"></vxe-column>
      <vxe-column field="defectAddress" title="缺陷隐患地址" align="center" minWidth="150"></vxe-column>
      <vxe-column field="taskName" title="任务名称" align="center" minWidth="150"></vxe-column> -->
    </vxe-table>
    <baseInfo ref="baseInfo"></baseInfo>
  </el-dialog>
</template>

<script>
import {workOrderManagement} from '@/api/defects/workOrderManagement.js'
import baseInfo from "./baseInfo.vue"

export default {
  name: "preparationTaskForm",
  props: {
    formData: {
      type: Object,
    },
  },
  components: {baseInfo},
  data() {
    return {
      dialogProps: {
        visible: false,
        title: "缺陷隐患数",
        width: "70%",
        top: "5px",
      },
      size: "small",
      periodShow: false,
      taskNoShow: false,
      list: {
        data: [],
        pageNo: 1,
        pageSize: 10,
        pageSizes: [10, 20, 50, 100],
        total: 0,
      },
      pagerShow: false,
      isEdit: false,
      isDisabled: false,
      row: {},


    };
  },
  mounted() {

  },
  methods: {
    showDialog(isEdit, row, isDisabled) {
      console.log(isEdit, row, isDisabled)
      this.isEdit = isEdit || false
      this.isDisabled = isDisabled || false
      this.row = row.row || {}
      this.dialogProps.visible = true
      this.getTable()
    },
    getTable() {
      workOrderManagement.getTaskEquipList(this.row.id).then(res => {
        this.list.data = res.data
        this.list.total = res.data.length
      }).catch(err => {
      })
    },
    handleBaseInfo(row) {
      this.$refs.baseInfo.showDialog(false, row)
    },
    handleClose(done) {

      this.$confirm("确认关闭？")
        .then((_) => {
          // this.handleCancel()
          this.dialogProps.visible = false;
          console.log("111")
        })
        .catch((_) => {
        });
    },
  },
};
</script>

<style scoped>
.tool-button-container {
  text-align: right;
}

.el-select {
  width: 100% !important
}
</style>
